<template>
  <div class="list-table">
    <div class="area-header">
      <span class="area-header-title">{{ $t('项目概览') }}</span>
    </div>
    <el-form ref="queryForm" :model="queryParams" :inline="true">
      <el-form-item :label="$t('项目名称')" prop="dealName">
        <el-input
          v-model="queryParams.dealName"
          :placeholder="$t('项目名称')"
          clearable
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t('搜索') }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" tooltip-effect="darkTable" :data="dealOverviewList" border>
      <el-table-column :label="$t('序号')" type="index" align="center" show-overflow-tooltip width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('项目名称')" align="center" prop="dealName" width="140" show-overflow-tooltip>
        <template slot-scope="scope">
          <router-link
            target="_blank"
            :to="{path:'/deal/home/dealBaseHome',query:{id:scope.row.dealId, companyId: scope.row.companyId}}"
            class="link_a"
          >{{ scope.row.dealName }}</router-link>
        </template>
      </el-table-column>
      <el-table-column :label="$t('负责人')" align="center" prop="personChargeName" width="110" show-overflow-tooltip />
      <el-table-column :label="$t('投资金额') + $t('金额单位')" align="center" prop="fk" width="100">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.fk, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('回款金额') + $t('金额单位')" align="center" prop="fk" width="100">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.hk, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('项目最新估值') + $t('金额单位')" align="center" prop="fk" width="130">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.gz, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('指标预警')" align="center" prop="riskType" width="130">
        <template slot-scope="scope">
          <span class="riskSpan">
            <el-link @click="showRiskDetails('red',scope.row)">
              <span class="risk-type-red" />
              <i> {{ scope.row.alarmCount }} </i>
            </el-link>
          </span>
          <span class="riskSpan">
            <el-link @click="showRiskDetails('yellow',scope.row)">
              <span class="risk-type-yellow" />
              <i>{{ scope.row.warmCount }}</i>
            </el-link>
          </span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('最新评级')" align="center" prop="grade" width="90">
        <template v-if="scope.row.assetRating" slot-scope="scope">
          <span :class="'grade-'+scope.row.assetRating" />
        </template>
      </el-table-column>
      <el-table-column :label="$t('项目风险')" prop="riskNum" align="center" show-overflow-tooltip width="90">
        <template slot-scope="scope">
          <span><el-link type="primary" @click="showDealRiskOpen(scope.row)">{{ scope.row.riskNum }}</el-link></span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('风险敞口金额') + $t('金额单位')" align="center" prop="riskExposureTotal" width="125">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.riskExposureTotal, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('风险损失金额') + $t('金额单位')" align="center" prop="riskLossTotal" width="125">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.riskLossTotal, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('负面新闻')" prop="negativeNewsNum" align="center" show-overflow-tooltip width="90">
        <template slot-scope="scope">
          <span><el-link type="primary" @click="showNegativeNews(scope.row)">{{ scope.row.negativeNewsNum }}</el-link></span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('异常经营')" prop="abnormalOperationNum" align="center" show-overflow-tooltip width="90">
        <template slot-scope="scope">
          <span><el-link type="primary" @click="showAbnormalOperation(scope.row)">{{ scope.row.abnormalOperationNum }}</el-link></span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('行政处罚')" prop="administrativeSanctionNum" align="center" show-overflow-tooltip width="90">
        <template slot-scope="scope">
          <span><el-link type="primary" @click="showAdministrativeSanction(scope.row)">{{ scope.row.administrativeSanctionNum }}</el-link></span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('法律诉讼')" prop="legalProceedingsNum" align="center" show-overflow-tooltip width="90">
        <template slot-scope="scope">
          <span><el-link type="primary" @click="showLegalProceedings(scope.row)">{{ scope.row.legalProceedingsNum }}</el-link></span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('失信信息')" prop="dishonestInformationNum" align="center" show-overflow-tooltip width="90">
        <template slot-scope="scope">
          <span><el-link type="primary" @click="showDishonestInformation(scope.row)">{{ scope.row.dishonestInformationNum }}</el-link></span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('法院公告')" prop="courtNoticeNum" align="center" show-overflow-tooltip width="90">
        <template slot-scope="scope">
          <span><el-link type="primary" @click="showCourtNotice(scope.row)">{{ scope.row.courtNoticeNum }}</el-link></span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 指标报警列表窗口 -->
    <el-dialog :title="$t('指标报警')" :visible.sync="riskOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class=" dialogView" width="80%" append-to-body>
      <riskDetailsList ref="riskDetailsList" :company-id="companyId" :risk-type="riskType" />
    </el-dialog>
    <!-- 风险管理列表窗口 -->
    <el-dialog :title="$t('风险管理')" :visible.sync="dealRiskOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class=" dialogView" width="80%" append-to-body>
      <dealRiskList ref="dealRiskList" :deal-id="dealId" />
    </el-dialog>
    <!-- 负面新闻列表窗口 -->
    <el-dialog :title="$t('负面新闻')" :visible.sync="newOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class=" dialogView" width="80%" append-to-body>
      <negativeNewsList ref="negativeNewsList" :company-id="companyId" />
    </el-dialog>
    <!-- 异常经营列表窗口 -->
    <el-dialog :title="$t('异常经营')" :visible.sync="abnormalOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class=" dialogView" width="80%" append-to-body>
      <abnormalOperationList ref="abnormalOperationList" :company-id="companyId" />
    </el-dialog>
    <!-- 行政处罚列表窗口 -->
    <el-dialog :title="$t('行政处罚')" :visible.sync="sanctionOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class=" dialogView" width="80%" append-to-body>
      <administrativeSanctionList ref="administrativeSanctionList" :company-id="companyId" />
    </el-dialog>
    <!-- 法律诉讼列表窗口 -->
    <el-dialog :title="$t('法律诉讼')" :visible.sync="legalOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class=" dialogView" width="80%" append-to-body>
      <legalProceedingsList ref="legalProceedingsList" :company-id="companyId" />
    </el-dialog>
    <!-- 失信信息列表窗口 -->
    <el-dialog :title="$t('失信信息')" :visible.sync="dishonestOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class=" dialogView" width="80%" append-to-body>
      <dishonestInformationList ref="dishonestInformationList" :company-id="companyId" />
    </el-dialog>
    <!-- 法院公告列表窗口 -->
    <el-dialog :title="$t('法院公告')" :visible.sync="courtOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class=" dialogView" width="80%" append-to-body>
      <courtNoticeList ref="courtNoticeList" :company-id="companyId" />
    </el-dialog>
  </div>
</template>

<script>
import { dealOverviewList } from '@/api/base/deal/dealBase'
import negativeNewsList from '@/views/deal/risk/dealOverview/negativeNewsList'
import abnormalOperationList from '@/views/deal/risk/dealOverview/abnormalOperationList'
import administrativeSanctionList from '@/views/deal/risk/dealOverview/administrativeSanctionList'
import legalProceedingsList from '@/views/deal/risk/dealOverview/legalProceedingsList'
import dishonestInformationList from '@/views/deal/risk/dealOverview/dishonestInformationList'
import courtNoticeList from '@/views/deal/risk/dealOverview/courtNoticeList'
import riskDetailsList from '@/views/deal/risk/dealOverview/riskDetailsList'
import dealRiskList from '@/views/deal/risk/dealRiskList'
export default {
    components: {
      riskDetailsList,
      negativeNewsList,
      abnormalOperationList,
      administrativeSanctionList,
      legalProceedingsList,
      dishonestInformationList,
      courtNoticeList,
      dealRiskList
    },
  data() {
      return {
          // 遮罩层
          loading: true,
          // 总条数
          total: 0,
          // 证券账户信息登记表格数据
          dealOverviewList: [],
          // 指标预警信息窗口开关
          riskOpen: false,
          // 风险管理窗口开关
          dealRiskOpen: false,
          // 负面新闻窗口开关
          newOpen: false,
          // 异常经营窗口开关
          abnormalOpen: false,
          // 行政处罚窗口开关
          sanctionOpen: false,
          // 法律诉讼窗口开关
          legalOpen: false,
          // 失信信息窗口开关
          dishonestOpen: false,
          // 法院公告窗口开关
          courtOpen: false,
          // 公司ID
          companyId: undefined,
          // 项目ID
          dealId: undefined,
          // 指标预警类型
          riskType: undefined,
          // 查询参数
          queryParams: {
            dealName: undefined,
            pageNum: 1,
            pageSize: 10
          },
          // 表单参数
          form: {},
          // 表单校验
          rules: {}
      }
  },
  created() {
      this.getList()
  },
  methods: {
    /** 查询证券账户信息登记列表 */
    getList() {
        this.loading = true
        dealOverviewList(this.queryParams).then(response => {
            this.dealOverviewList = response.rows
            this.total = response.total
            this.loading = false
        })
    },
    /** 搜索按钮操作 */
    queryHandle() {
        this.queryParams.pageNum = 1
        this.getList()
    },
    /** 打开负面新闻列表 */
    showRiskDetails(type, row) {
      this.riskOpen = true
      this.riskType = type
      this.companyId = row.companyId
      this.$nextTick(() => {
        // 调用form页面的 init 方法初始化数据
        this.$refs.riskDetailsList.getList(row)
      })
    },
    /** 打开负面新闻列表 */
    showNegativeNews(row) {
      this.newOpen = true
      this.companyId = row.companyId
      this.$nextTick(() => {
        // 调用form页面的 init 方法初始化数据
        this.$refs.negativeNewsList.getList(row)
      })
    },
    /** 打开负面新闻列表 */
    showDealRiskOpen(row) {
      this.dealRiskOpen = true
      this.dealId = row.dealId
      this.$nextTick(() => {
        // 调用form页面的 init 方法初始化数据
        this.$refs.dealRiskList.getList(row)
      })
    },
    /** 打开异常经营列表 */
    showAbnormalOperation(row) {
      this.abnormalOpen = true
      this.companyId = row.companyId
      this.$nextTick(() => {
        // 调用form页面的 init 方法初始化数据
        this.$refs.abnormalOperationList.getList(row)
      })
    },
    /** 打开行政处罚列表 */
    showAdministrativeSanction(row) {
      this.sanctionOpen = true
      this.companyId = row.companyId
      this.$nextTick(() => {
        // 调用form页面的 init 方法初始化数据
        this.$refs.administrativeSanctionList.getList(row)
      })
    },
    /** 打开法律诉讼列表 */
    showLegalProceedings(row) {
      this.legalOpen = true
      this.companyId = row.companyId
      this.$nextTick(() => {
        // 调用form页面的 init 方法初始化数据
        this.$refs.legalProceedingsList.getList(row)
      })
    },
    /** 打开失信信息列表 */
    showDishonestInformation(row) {
      this.dishonestOpen = true
      this.companyId = row.companyId
      this.$nextTick(() => {
        // 调用form页面的 init 方法初始化数据
        this.$refs.dishonestInformationList.getList(row)
      })
    },
    /** 打开法院公告列表 */
    showCourtNotice(row) {
      this.courtOpen = true
      this.companyId = row.companyId
      this.$nextTick(() => {
        // 调用form页面的 init 方法初始化数据
        this.$refs.legalProceedingsList.getList(row)
      })
    },
    /** 重置按钮操作 */
    resetQuery() {
        this.dateCreateTime = []
        this.resetForm('queryForm')
        this.queryHandle()
    }
  }
}
</script>
